package cn.wolfcode.rbac.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

@Getter
@Setter
public class CourseOrder {
    private Long id;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date inputTime; // 销售时间（录入时间）

    private Customer customer;    // 潜在客户

    private SystemDictionaryItem course;      // 购买课程

    private Long money;         // 销售金额

    public String getJson(){
        HashMap<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("money",money);
        if(customer != null){
            map.put("customerId",customer.getId());
        }
        if(course != null){
            map.put("courseId",course.getId());
        }

        return JSON.toJSONString(map);
    }

}